from pathlib import Path

promot = 'please write your name: \n'
file = Path('gust.txt')
while True:
    name = input(promot)
    if name != 'q':
        content = file.read_text() + name + '\n'
        file.write_text(content)
    else:
        break
